/*********************
* Author:Dzlua
* QQ:505544956
* time:2016/09/07
*/
#ifndef __EDUI_CHECKBOX_H__
#define __EDUI_CHECKBOX_H__

#include "Button.h"

EDUI_NAMESPACE_BEGIN

class EDUI_API CheckBox : public Button
{
public:
    struct {
        Event1<CheckBox*> selected;
    } evt;
protected:
    CheckBox();
    virtual ~CheckBox();
public:
	static CheckBox* GetInterface();
	virtual void Release();
    static CheckBox* ToCheckBox(Control* ctrl);
public:
    bool IsSelected();
    /*event:handle event,bNotify:notify other CheckBox in one group*/
    void SetSelect(bool bSelected, bool bEvent = true, bool bNotify = true);

    void SetGroup(const char* group);
    const char* GetGroup();

    bool BindTableLayout(const char* name, int index);
    const char* GetBindTableLayoutName();
    int GetBindTableLayoutIndex();

protected:
    virtual bool HandleMsg(Msg* msg);
    virtual void RenderStatusImages(IRender* render, const Rect* rc);
    virtual void RenderText(IRender* render, const Rect* rc);

    virtual void SetAttribute(const char* name, const char* value);

    virtual Color* GetDestColor(const char* dstname);
    virtual ImageData* GetDestImageData(const char* dstname);

    virtual void DoEvent(EventType type, void* data1 = 0, void* data2 = 0);
    void DoBindEvent();
protected:
    ImageData m_selNormalImage;
    ImageData m_selHotImage;
    ImageData m_selPressedImage;
    ImageData m_selDisabledImage;

    Color m_selTextColor;
    Color m_selHotTextColor;
    Color m_selPressedTextColor;
    Color m_selDisabledTextColor;

    bool m_bSelected;

    char* m_group;
    char* m_bindTableLayoutName;
    int m_bindTableLayoutIndex;
};

EDUI_NAMESPACE_END

#endif
